home *** CD-ROM | disk | FTP | other *** search
- /* testdisp.c - test viewdisp.c (display_page and disp_char) */
- #include "stdio.h"
- #include "cminor.h"
- #include "viewparm.h"
-
- char filename[81] ;
- char s[256] ;
- extern int row , col ;
- long filesize ;
- long top_of_page ;
- int ix ; /* index to character string */
- int silent ; /* flag for get_next_char */
-
- /* test viewdisp module */
- main()
- {
- int c ;
- char a ;
- int i ;
-
- printf("\n testing disp_char") ;
- while( 1 == 1 )
- {
- printf("\n char (decimal):") ;
- scanf ("%d",&c) ;
- if( c == -1 ) break ;
- printf("\n col:") ;
- scanf("%d",&col) ;
- printf("\n row:") ;
- scanf("%d",&row) ;
- printf("\n1234567890\n") ;
-
- for( i=1 ; i < col ; i = i+1 )
- {
- printf(">") ;
- }
- disp_char(c) ;
- printf("< row = %d col + %d \n",row,col) ;
- }
-
- printf("\n\n testing display_page \n") ;
-
- strcpy(filename,"< file name >") ;
- top_of_page = 333000000 ;
- filesize = 444000000 ;
-
-
- silent = 0 ;
- printf("\n show get_next_char calls\n") ;
- display_page() ;
-
-
- printf("\n test with get_next_char silent\n") ;
- silent = 1 ;
- printf("\n test with full page-no output from get_next_char\n") ;
- strcpy(s,"1234567890") ;
- ix = 0 ;
- display_page() ;
- scanf("%c%c",&a,&a) ; /* pause before next test */
- printf("\n test with EOF in 3rd line-no get_next_char out.\n") ;
- strcpy(s,"1\n2\n\f") ;
- ix = 0 ;
- display_page() ;
- }
-
-
- int get_next_char()
- {
- int c ;
-
- if( silent == 0 )
- { printf("\n get_next_char called\n") ;
- printf("\n row = %d col + %d \n",row,col) ;
- printf("value to return:") ;
- scanf("%d",&c) ;
- return(c) ;
- }
- else if( s[ix] == '\0' ) /* at end of string */
- { ix = 0 ; /* start over in string */
- return("\n" ) ; /* and return Newline char */
- }
- else /* not at end of string return char */
- { c = tochar( s[ix] ) ;
- ix = ix + 1 ;
- if( c == '\f' ) c = EOF_MARK ;
- return(c) ;
- }
- }
-
- int move_to(pos)
- long pos ;
- {
- printf("\n move to called - position = %1d \n") ;
- }